package de.preisrobot.persistence.dao;

import javax.persistence.EntityManager;

public interface Dao<T> {
    public void persist(T transientInstance);

    public void remove(T persistentInstance);

    public T merge(T detachedInstance);
    
    /**
     * This method is used to get a proxied instance of an entity.
     * It delegates to {@link EntityManager#getReference(Class, Object)}.
     * See also the <a href="http://docs.jboss.org/hibernate/entitymanager/3.5/reference/en/html/objectstate.html#d0e1061">documentation</a>
     * associated on hibernate's website.
     * @param clazz the class of the entity
     * @param id the identifier of the identity
     * @return a proxied instance of the entity with the identifier specified
     */
    public <U> U getReference(Class<U> clazz, Object id);

	void flush();

	void refresh(T entity);
}
